// pages/add_logistics_info/index.js
var router = require('../../utils/router/index.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    const data = router.extract(options);
    if(data.donate_id != null & 
      data.donate_name != null &
      data.hospital_id != null &
      data.hospital_name != null 
      ){
        this.setData({
          donate_id:data.donate_id,
          donate_name:data.donate_name,
          hospital_id: data.hospital_id,
          hospital_name: data.hospital_name
        })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  /**
   * 保存物流信息并返回
   */
  save_logistics:function(){
    var that = this
    if(that.data.wlc == '' || that.data.wlsn == ''){
      return
    }
    router.push({
      name: 'add_donationlist',
      data: {
        wlsn:  that.data.wlsn,
        wlc: that.data.wlc,
        donate_id: that.data.donate_id,
        donate_name:that.data.donate_name,
        hospital_id: that.data.hospital_id,
        hospital_name: that.data.hospital_name
      },
    });
  },

  /**
   * 物流单号
   */
  bindwlsnInput: function(e){
    var that = this
    console.log(e.detail.value)
    this.setData({
      wlsn: e.detail.value
    })
  },

  /**
   * 物流公司
   */
  bindwlcInput: function(e){
    var that = this
    console.log(e.detail.value)
    this.setData({
      wlc: e.detail.value
    })
  },
})